<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>判断选中的复选框个数</title>
    <script type="text/javascript" src="../../js/jquery-1.11.0.js"></script>
</head>
<body>
    <input type="checkbox" name="check" id="check1" checked />
    <label for="check1">水果</label>
    <input type="checkbox" name="check" id="check2" checked />
    <label for="check2">蔬菜</label>
    <input type="checkbox" name="check" id="check3" checked />
    <label for="check3">饮料</label>
    <input type="text" value="" />
    <input type="btn" value="点击显示被选中的复选框倍数">
</body>
<script>
    var checkedArray = [];                          //创建空数组
    var checks = $("input[type='checkbox']");          //获取所有name值为check的input标签
    var btn = $("input[type='btn']");
    btn.click(function(){
        for(var i=0;i<checks.length;i++) {
            if (checks.is(":checked")) {
                checkedArray.push(checks[i].value);
            }
        }
        $("input[type='text']").val(checkedArray.length);
    })
</script>
</html>